package com.lagou.cluster.web;

import com.lagou.cluster.entity.JobInfo;
import com.lagou.cluster.service.JobInfoMapService;
import com.lagou.cluster.service.JobInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/jobInfo")
public class JobInfoController {

    @Autowired
    private JobInfoService jobInfoService;

    @Autowired
    private JobInfoMapService jobInfoMapService;

    @RequestMapping("/list")
    public List list() {
        return this.jobInfoService.list();
    }

    @RequestMapping("/save")
    public int save(@RequestBody JobInfo info) {
        return this.jobInfoService.save(info);
    }

    /**
     * 另外一个service的测试
     * @param info
     * @return
     */
    @RequestMapping("/saveMap")
    public int saveMap(@RequestBody JobInfo info) {
        return this.jobInfoMapService.save(info);
    }

    @RequestMapping("/getById/{id}")
    public JobInfo getById(@PathVariable("id") int id) {
        return this.jobInfoMapService.getById(id);
    }
}
